package com.snowRemovingUser.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.domain.TLogininfor;
import com.ruoyi.framework.service.ITLogininforService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 除雪防滑系统访问记录Controller
 *
 * @author liguang
 * @date 2023-04-13
 */
@RestController
@RequestMapping("/snowRemoving/logininfor")
public class TLogininforController extends BaseController
{
    @Autowired
    private ITLogininforService tLogininforService;

    /**
     * 查询除雪防滑系统访问记录列表
     */
    @PreAuthorize("@ss.hasPermi('snowRemoving:logininfor:list')")
    @GetMapping("/list")
    public TableDataInfo list(TLogininfor tLogininfor)
    {
        startPage();
        List<TLogininfor> list = tLogininforService.selectTLogininforList(tLogininfor);
        return getDataTable(list);
    }

    /**
     * 导出除雪防滑系统访问记录列表
     */
    @PreAuthorize("@ss.hasPermi('snowRemoving:logininfor:export')")
    @Log(title = "除雪防滑系统访问记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TLogininfor tLogininfor)
    {
        List<TLogininfor> list = tLogininforService.selectTLogininforList(tLogininfor);
        ExcelUtil<TLogininfor> util = new ExcelUtil<TLogininfor>(TLogininfor.class);
        util.exportExcel(response, list, "除雪防滑系统访问记录数据");
    }

    /**
     * 获取除雪防滑系统访问记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('snowRemoving:logininfor:query')")
    @GetMapping(value = "/{infoId}")
    public AjaxResult getInfo(@PathVariable("infoId") Long infoId)
    {
        return success(tLogininforService.selectTLogininforByInfoId(infoId));
    }

    /**
     * 新增除雪防滑系统访问记录
     */
    @PreAuthorize("@ss.hasPermi('snowRemoving:logininfor:add')")
    @Log(title = "除雪防滑系统访问记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TLogininfor tLogininfor)
    {
        return toAjax(tLogininforService.insertTLogininfor(tLogininfor));
    }

    /**
     * 修改除雪防滑系统访问记录
     */
    @PreAuthorize("@ss.hasPermi('snowRemoving:logininfor:edit')")
    @Log(title = "除雪防滑系统访问记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TLogininfor tLogininfor)
    {
        return toAjax(tLogininforService.updateTLogininfor(tLogininfor));
    }

    /**
     * 删除除雪防滑系统访问记录
     */
    @PreAuthorize("@ss.hasPermi('snowRemoving:logininfor:remove')")
    @Log(title = "除雪防滑系统访问记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{infoIds}")
    public AjaxResult remove(@PathVariable Long[] infoIds)
    {
        return toAjax(tLogininforService.deleteTLogininforByInfoIds(infoIds));
    }
}
